﻿<cfsilent>
	<cfscript>
		
		event.setArg("pageTitle", "教学运行管理 - 考试安排 - 期中考试指定时间");

		termId = event.getArg("TermID");
		academicYear = event.getArg("AcademicYear");
		academicTerm = event.getArg("AcademicTerm");

		examId = event.getArg("EXID");

		currentTab = event.getArg("TabID", "labArrange");
		
		passArgs = structNew();
		
		/* 加载考试任务 */
		sql = "SELECT 
					a.wid, a.task_prog, 
					b.course_name 
				FROM t_examtask a 
				INNER JOIN t_course b ON a.cid = b.cid 
				WHERE 
					a.task_exid = :examId ";
					
		queryObj = new Query( datasource=application.dnsSlave ); 
		queryObj.addParam( name="examId", value=examId, cfsqltype="cf_sql_char" );
		
		rs_exam = queryObj.execute( sql=sql ).getResult();

	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('examMidArrange')#</cfoutput>"><i class="mrs img btnList"></i><span class="uiButtonText">期中考试安排</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 courseTable"></i>《<cfoutput>#rs_exam.course_name#</cfoutput>》 - 指定考试时间
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix">
				
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labArrange">class="active"</cfif> id="labArrange" tabTarget="Arrange">考试时间</span>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>
				</script>
				
				<div id="Arrange" class="tabContent">
					
					<div class="noticeBlock">
						<h3>《<cfoutput>#rs_exam.course_name#</cfoutput>》</h3>
						<p>
							<span class="img icon16x16 message"></span><em><cfoutput>#academicYear#</cfoutput>-<cfoutput>#academicTerm#</cfoutput></em>学期期中考试安排.
							该门课程考试计划安排于 <em id="weekLable"><cfoutput>#rs_exam.wid#</cfoutput></em> 周
						</p>
						
						<div class="UIArrangeOper">
							
							<cfif rs_exam.task_prog eq "0">
								<!-- formChangeWeek -->
								<span>调整考试周次</span><input class="filedExamWeek" id="examWeek" type="text" maxlength="2" value="<cfoutput>#int(rs_exam.wid)#</cfoutput>" /><input id="examWeekTrigger" class="btnSubmit" type="button" value="保存" />
								<script language="javascript" type="text/javascript">
									//<![CDATA[
									<!--
									function changeExamWeek() {

										var examWeek = $("#examWeek").val();
										
										if ( isNumeric(examWeek) ) {
											
											/* 更改周次阻挡 */
											$.blockUI({ 
													message: '重新计算周次冲突...',
													css: { 
														'width': '22%',
														'left': '42%',
														'border': 'none', 
														'padding': '15px 5px', 
														'backgroundColor': '#333', 
														'border-radius': '4px', 
														'opacity': .8, 
														'color': '#fff',
														'cursor': null
														},
												overlayCSS: {
														'backgroundColor': '#000', 
														'opacity': .1 ,
														'cursor': null
														}
												});
											
											$.post(
													"<cfoutput>#buildURL('apiExamTaskChangeWeek')#</cfoutput>",
													{
														'exid' : '<cfoutput>#examId#</cfoutput>',
														'wk' : examWeek, 
														'seed': (new Date()).getTime()
													},
													function(data) {

														result = $.parseJSON(data);
														
														if (result.success) {

															/* 更新周次标识 */
															$("#weekLable").text(result.ExamWeek);
															
															/* 刷新考试时间占用情况表 */
															$.post(
																	"<cfoutput>#buildURL('apiExamMidTimeTable')#</cfoutput>",
																	{
																	'exid' : '<cfoutput>#examId#</cfoutput>',
																	'seed': (new Date()).getTime()
																	},
																	function(data) {
																		$("#examTaskTimeTable").html(data);
																	});
															
														}
														else {
															alert(result.reason);
														}
														
													});
											
											/* 延迟1秒 取消阻挡 */
											$('body').oneTime('1s',function(){
												$.unblockUI();
											});
											
										}
										else {
											alert("请正确填写周次数字");
										}
										
									}
								
									$(document).ready(function() {
									
										/* 绑定事件响应 */
										$("#examWeekTrigger").click(function(){
											changeExamWeek();
										});
									
										$("#examWeek").keydown(function(event) {
											var keyCode = event.keyCode;
											if (keyCode == 13) {
												changeExamWeek();
											}
										});
									});
									// -->
									//]]>
								</script>
								<!-- /formChangeWeek -->
							</cfif>
						</div>
					</div>
					
					<div id="examTaskTimeTable">
						<!--- 显示考试时间安排表 --->
						<!-- examTimeTable -->
						<cfoutput>#event.getArg("examMidTaskTimeTable")#</cfoutput>
						<!-- /examTaskTimeTable -->
					</div>
					
				</div>
			
			</div>
		</li>
	</ul>
</div>